import { VxeGridPropTypes } from '@/components/VxeTable';
import { Tag, Image } from 'ant-design-vue';
import { h } from 'vue';
const uploadUrl = '';
export default [
  {
    title: '提供者',
    field: 'provider'
  },
  {
    title: '仓储名称',
    field: 'bucketName'
  },
  {
    title: '文件名称',
    field: 'fileName'
  },
  {
    title: '文件后缀',
    field: 'suffix',
    slots: {
      default: ({ row }) => {
        return h(Tag, { color: 'blue' }, () => row.suffix);
      }
    }
  },
  {
    title: '预览',
    field: 'sysFlag',
    slots: {
      default: ({ row }) => {
        const record = row;
        if (
          record.suffix.indexOf('png') > 0 ||
          record.suffix.indexOf('jpg') > 0 ||
          record.suffix.indexOf('bmp') > 0
        ) {
          const filePath = record.url
            ? record.url
            : uploadUrl +
              '/' +
              record.filePath +
              '/' +
              record.id +
              record.suffix;
          return h(Image, {
            size: 60,
            simpleShow: true,
            src: filePath
          });
        } else return h(Tag, { color: 'orange' }, () => '无法预览');
      }
    }
  },
  {
    title: '大小KB',
    field: 'sizeKb'
  },
  {
    title: '创建时间',
    field: 'createTime',
    visible: false
  },
  {
    width: 140,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right'
  }
] as VxeGridPropTypes.Columns;
